package com.qujia.station.controller;

import com.baomidou.mybatisplus.extension.api.R;
import com.github.pagehelper.PageInfo;
import com.qujia.common.core.controller.BaseController;
import com.qujia.common.core.domain.AjaxResult;
import com.qujia.station.domain.dto.StorageRecordsQueryDto;
import com.qujia.station.domain.dto.StorageRecordsUpdateDto;
import com.qujia.station.domain.vo.StorageRecordsVo;
import com.qujia.station.service.StorageRecordsService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@Api(tags = "商品调拨入库接口")
@RestController
@RequestMapping("/storageRecords")
public class StorageRecordsController extends BaseController {

    @Autowired
    private StorageRecordsService storageRecordsService;

    @GetMapping("/selectStorageRecordsDetails/{storageRecordsId}")
    @ApiOperation(value = "查询商品调拨入库详情", httpMethod = "GET")
    public AjaxResult selectStorageRecordsDetails(@PathVariable Long storageRecordsId){
        return AjaxResult.success(storageRecordsService.selectStorageRecordsDetails(storageRecordsId));
    }

    @PostMapping("/selectStorageRecordsList/list")
    @ApiOperation(value = "查询商品入库列表", httpMethod = "POST")
    public R<PageInfo> selectStorageRecordsList(@RequestBody StorageRecordsQueryDto storageRecordsQueryDto){
        PageInfo<StorageRecordsVo> pageInfo = storageRecordsService.selectStorageRecordsList(storageRecordsQueryDto);
        return R.ok(pageInfo);
    }

    @PostMapping("/updateStorageRecords/update")
    @ApiOperation(value = "修改调拨入库数量", httpMethod = "POST")
    public AjaxResult updateStorageRecords(@RequestBody StorageRecordsUpdateDto storageRecordsUpdateDto){
        return AjaxResult.success(storageRecordsService.updateStorageRecords(storageRecordsUpdateDto));
    }

    @PostMapping("/confirmStorage/confirm")
    @ApiOperation(value = "确认入库", httpMethod = "POST")
    public AjaxResult confirmStorage(@RequestBody StorageRecordsUpdateDto storageRecordsUpdateDto){
        return AjaxResult.success(storageRecordsService.confirmStorage(storageRecordsUpdateDto));
    }
}
